﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TesteOnline.Model;
using System.Data.SqlServerCe;
using MySql.Data.MySqlClient;

namespace TesteOnline.Bll
{
    public class Wrapper
    {

        public void AddNewQuestion(int idMateria, Question q)
        {
            MySqlConnection mConn;
            System.Data.DataSet ds = new DataSet();
            List<Disciplines> ret = new List<Disciplines>();
            mConn = new MySqlConnection("Persist Security Info=False;server=localhost;database=provadb;uid=root;server=localhost;database=quizdb;uid=root;pwd=''");
            mConn.Open();
            string stringCommand = "INSERT INTO `quizdb`.`questao` (`Texto`,`Tipo`,`DataCriacao`,`idUsuario`,`idMateria`,`Gabarito`)VALUES({Texto: LONGTEXT},{Tipo: INT},{DataCriacao: DATETIME},{idUsuario: INT},{idMateria: INT},{Gabarito: INT});";
            MySqlCommand commnand = new MySqlCommand(stringCommand);




            mConn.Close();
        }

        public Avaliation GetAvaliation()
        {
            Avaliation av = new Avaliation();
            av.Questions.Add(1, new Question("1+1=2", true));
            av.Questions.Add(2, new Question("1+1=3", false));
            return av;
        }

        public List<Disciplines> GetDisciplines()
        {
            MySqlConnection mConn;
            List<Disciplines> ret = new List<Disciplines>();

            mConn = new MySqlConnection("Persist Security Info=False;server=localhost;database=provadb;uid=root;server=localhost;database=quizdb;uid=root;pwd=''");
            mConn.Open();
            MySqlCommand command = new MySqlCommand("SELECT * FROM MATERIA", mConn);
            MySqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                ret.Add(new Disciplines((int)reader["idMateria"], reader["Nome"].ToString()));
            }
            mConn.Close();


            return ret;
        }
    }
}